lib/util: Fix segfault when validating filename
authorAllen Bai <abai@localhost.localdomain>
Wed, 5 Jun 2019 14:30:31 +0000 (10:30 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 6 Jun 2019 16:05:19 +0000 (16:05 +0000)
This change fixes the segfault issue when calling ostree_repo_checkout_tree with
empty GFileInfo. A simple condition check for NULL value is added at
src/libotutil/ot-unix-utils.c:46. Closes: ostreedev#1864.

Closes: #1868
Approved by: jlebon

src/libotutil/ot-unix-utils.c

index 7778ca114c4afea42cb07b0867d693a36c25ebc8..17016ae152530b689f7a5c6cdced766b2695f8e6 100644 (file)
@@ -43,6 +43,8 @@ gboolean
 ot_util_filename_validate (const char *name,
                            GError    **error)
 {
+  if (name == NULL)
+    return glnx_throw (error, "Invalid NULL filename");
   if (strcmp (name, ".") == 0)
     return glnx_throw (error, "Invalid self-referential filename '.'");
   if (strcmp (name, "..") == 0)